home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / CMPLTPAS / SAVESCRN.PAS < prev    next >
Pascal/Delphi Source File  |  1988-07-17  |  3KB  |  67 lines

  1. {->>>>SaveScreen<<<<-------------------------------------------}
  2. {                                                              }
  3. { Filename : SAVESCRN.SRC -- Last Modified 7/14/88             }
  4. {                                                              }
  5. { This routine saves the current display buffer out to the     }
  6. { heap, regardless of how large the current display format is. }
  7. { The routine queries the BIOS to determine how many lines are }
  8. { currently on the screen, and saves only as much data to the  }
  9. { heap as necessary.                                           }
  10. {                                                              }
  11. { Use the companion routine, RestoreScreen, to bring a screen  }
  12. { back from the heap.                                          }
  13. {                                                              }
  14. {     From: COMPLETE TURBO PASCAL 5.0  by Jeff Duntemann       }
  15. {    Scott, Foresman & Co., Inc. 1988   ISBN 0-673-38355-5     }
  16. {--------------------------------------------------------------}
  17.  
  18. PROCEDURE SaveScreen(VAR StashPtr : Pointer);
  19.  
  20. TYPE
  21.   VidPtr   = ^VidSaver;
  22.   VidSaver = RECORD
  23.                Base,Size : Word;
  24.                BufStart  : Byte
  25.              END;
  26.  
  27. VAR
  28.   VidBuffer : Pointer;
  29.   Adapter   : AdapterType;
  30.   StashBuf  : VidSaver;
  31.   VidVector : VidPtr;
  32.  
  33. BEGIN
  34.   Adapter := QueryAdapterType;
  35.   WITH StashBuf DO
  36.     BEGIN
  37.       CASE Adapter OF
  38.         MDA,EGAMono,VGAMono,MCGAMono : Base := $B000;
  39.         ELSE Base := $B800;
  40.       END;  { CASE }
  41.       CASE DeterminePoints OF
  42.         8  : CASE Adapter OF
  43.                CGA              : Size := 4000;  { 25-line screen }
  44.                EGAMono,EGAColor : Size := 6880;  { 43-line screen }
  45.                ELSE               Size := 8000;  { 50-line screen }
  46.              END; { CASE }
  47.         14 : CASE Adapter OF
  48.                EGAMono,EGAColor : Size := 4000;  { 25-line screen }
  49.                ELSE               Size := 4320;  { 27-line screen }
  50.              END; { CASE }
  51.         16 : Size := 4000;
  52.       END; { CASE }
  53.       VidBuffer := Ptr(Base,0);
  54.     END;
  55.  
  56.   GetMem(StashPtr,StashBuf.Size+4);  { Allocate heap for whole shebang }
  57.   { Here we move *ONLY* the VidSaver record (5 bytes) to the heap: }
  58.   Move(StashBuf,StashPtr^,Sizeof(StashBuf));
  59.   { This casts StashPtr, a generic pointer, to a pointer to a VidSaver: }
  60.   VidVector := StashPtr;
  61.   { Now we move the video buffer itself to the heap.  The vide data is }
  62.   { written starting at the BufStart byte in the VidSaver record, and  }
  63.   { goes on for Size bytes to fit the whole buffer.  Messy but hey, this }
  64.   { is PC land! }
  65.   Move(VidBuffer^,VidVector^.BufStart,StashBuf.Size);
  66. END;
  67.